﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AchievementPage.aspx.cs" Inherits="FBKPI.Pages.AchievementPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var oTable;
        $(document).ready(function () {
            mainmenu("#nav ul", "#nav li");
            mainmenu("#menu_wrap ul", "#menu_wrap li");

            //datatable section
            oTable = $("#KPIAssignDetailTable").dataTable({
                "oLanguage": {
                    "sZeroRecords": "No records to display",
                    "sSearch": "Search"
                },
                "bSort": true,
                "bPaginate": true,
                "bAutoWidth": false,
                "bProcessing": true,
                "bServerSide": true,
                "bDestroy": true,
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bDeferRender": true,
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "GET",
                        "url": "../Serializer/KPIAssignDetailByUserIDSerializer.ashx?CurrentUser=" + $("#txt_user").val() + "&Year=" + $("#txt_selectyear").val(),
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                "aoColumns": [
             {
                 "mData": "KPI", "sWidth": "3%"
             },
            {
                "mData": "No", "sWidth": "3%"
            }, {
                "mData": "KPIDescription"
            }, {
                "mData": "AssignedTo"
            }, 

//             {
//                "mData": "UoM"
//            },
            
             
            
             {
             "mData": "Periode", "sWidth": "8%"
            }, {
                "mData": "Year"
            }, {
                "mData": "ScoredBySystem"
            }, {
                "mData": "Weight", "sWidth": "8%"
            },

            {
                "mData": "UoMMax"
            },
            {
                "mData": "UoMMin"
            },
            {
                "mData": "isActive", "sWidth": "8%"
            },
            {
                "mData": "KPIAssign"
            }, {
                "mData": "KPIAssignDetail"
            }],
                "aoColumnDefs": [{
                    "fnRender": function (oObj) {
                        return "<a href=\"#\" onclick=\"DirectTo('" + oObj.aData["KPI"] + "','" + oObj.aData["KPIAssign"] + "','" + oObj.aData["KPIAssignDetail"] + "', '" + $("#txt_user").val() + "')\"><img src='../images/detail.png' /></a>";
                    },
                    "aTargets": [0]
                }, {
                    "fnRender": function (oObj) {
                        if (oObj.aData["isActive"] == 'True') {
                            return "<img src='../images/check.png' />"
                        } else {
                            return "<img src='../images/cross.png' />"
                        }
                    },
                    "aTargets": [10]
                },
                
//                 {
//                    "fnRender": function (oObj) {
//                        if (oObj.aData["ScoredBySystem"] == 'True') {
//                            return "<img src='../images/check.png' />"
//                        } else {
//                            return "<img src='../images/cross.png' />"
//                        }
//                    },
//                    "aTargets": [7]
//                }, 
                
                {
                    "sClass": "center",
                    "aTargets": [0, 1, 11,7,10]
                }
            , {
                "bVisible": false,
                "aTargets": [3, 11, 12, 5, 6]//
            }

            ]
            });

            //mark selected row
            $('body').on("click", '#KPIAssignDetailTable tbody tr', function () {
                $('#KPIAssignDetailTable tbody tr').removeClass("row_selected");
                $(this).addClass("row_selected");
            });
            //--------------------end of mark selected row-----------------------------
            //$("#KPIAssignDetailTable_filter label").after('&nbsp;KPI Year: <input id=\"txt_selectyear\" oninput=\'GetList($(this).val());\' type=\"text\" \>');
            //--------------------end of datatable section-----------------------------------------
            DirectTo = function (KPIID, KPIAssignID, KPIAssignDetailID, user) {
                document.location = "../Pages/InputAchievementPage.aspx?User=" + user + "&KPI=" + KPIID + "&KPIAssign=" + KPIAssignID + "&KPIAssignDetail=" + KPIAssignDetailID;
                return false;
            }
        });

        GetList = function (value) {
            if (value.length > 0) {
                var xx = '0123456789';
                if (xx.indexOf(value[value.length - 1]) < 0) {
                    $("#txt_selectyear").val(value.toString().replace(value[value.length - 1], ''));
                }

                if (value.length == 4) {
                    oTable.fnDraw();
                }
            }
            else
            { oTable.fnDraw(); }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 <div style="height: 525px; overflow: auto;">
    <div id="kpiassigndetailtable">
        <div>
            <div class="customPageHeader">
                <span class="customPageTitle">KPI Achievement</span>
            </div>
            <div class="ui-widget-content">
                <table cellpadding="0" cellspacing="0" class="display" id="KPIAssignDetailTable">
                    <thead>
                        <tr>
                            <th>
                            </th>
                            <th>
                                No
                            </th>
                            <th>
                                KPI Description
                            </th>
                            <th>
                                Assigned To
                            </th>
                           
                           <%-- <th>
                                UoM
                            </th>--%>
                           
                            <th>
                                Period
                            </th>
                            <th>
                                Year
                            </th>
                            <th>
                                Scored By System
                            </th>
                            <th>
                                Weight
                            </th>
                             <th>
                                UoM Max
                            </th>
                            <th>
                                UoM Min
                            </th>
                             <th>
                                is Active
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
        <br />
    </div>
    </div>
</asp:Content>
